#!/usr/bin/env python
# -*- coding: utf-8 -*-
#本代码来自所出售产品的淘宝店店主编写
#未经受权不得复制转发
#淘宝店：https://fengmm521.taobao.com/
#再次感谢你购买本店产品
import os
import pathtool


def getDeivcesForMDevice(mFPth):
    f = open(mFPth,'r')
    dat = f.read()
    f.close()
    dat = dat.replace('\r','').replace('\t','').replace(' ','')
    devs = dat.split('\n')
    return devs

#设置板子运行参数
def allDevices():
    outdict = {}
    setDirpth = pathtool.cur_file_dir() + os.sep + 'allDevices'
    files = pathtool.getAllExtFile(setDirpth,'.txt')
    print(files)
    for i,v in enumerate(files):
        fpth = setDirpth + v[0]
        outdict[v[2]] = getDeivcesForMDevice(fpth)
    return outdict

#设置板子运行参数
def setDevices():
    outdict = {}
    setDirpth = pathtool.cur_file_dir() + os.sep + 'setDevices'
    files = pathtool.getAllExtFile(setDirpth,'.txt')
    print(files)
    for i,v in enumerate(files):
        fpth = setDirpth + v[0]
        outdict[v[2]] = getDeivcesForMDevice(fpth)
    return outdict
#运行板子
def startDevices():
    outdict = {}
    setDirpth = pathtool.cur_file_dir() + os.sep + 'runDevices'
    files = pathtool.getAllExtFile(setDirpth,'.txt')
    print(files)
    for i,v in enumerate(files):
        fpth = setDirpth + v[0]
        outdict[v[2]] = getDeivcesForMDevice(fpth)
    return outdict

#停卡板子运行
def stopDevices():
    outdict = {}
    setDirpth = pathtool.cur_file_dir() + os.sep + 'runDevices'
    files = pathtool.getAllExtFile(setDirpth,'.txt')
    print(files)
    for i,v in enumerate(files):
        fpth = setDirpth + v[0]
        outdict[v[2]] = getDeivcesForMDevice(fpth)
    return outdict

def test():
    setDevices()

if __name__ == '__main__':
    test()